home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.unix.programmer,comp.lang.c
- Subject: Re: Runtime ANSI C checking tool?
- Date: Sun, 10 Mar 96 16:19:16 GMT
- Organization: none
- Message-ID: <826474756snz@genesis.demon.co.uk>
- References: <DnI89B.EnH@pgh.nauticom.net> <p5ag239ede.fsf@lemming.wellfleet.com> <TANMOY.96Mar7180501@qcd.lanl.gov>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <TANMOY.96Mar7180501@qcd.lanl.gov>
- tanmoy@qcd.lanl.gov "Tanmoy Bhattacharya" writes:
-
- >In article <826219697snz@genesis.demon.co.uk>
- >Lawrence Kirby <fred@genesis.demon.co.uk> writes:
- >
- >LK: >Well, a well-written ANSI C compiler should handle all language
- >LK: >violations, and a well-written ANSI C system library should catch all
- >LK: >runtime violations (passing NULL to strcpy() or something, for
- >LK: >example).
- >LK:
- >LK: Not possible in general (at least for the compiler or the standard library)
- >LK: e.g.
- >LK:
- >LK: int foo(int *p, int *q)
- >LK: {
- >LK: return ++*p + ++*q;
- >LK: }
- >LK:
- >LK: This results in undefined behaviour if the same value is passed for p and
- >LK: q.
- >
- >Well, it is possible for the compiler to put in a runtime check :-)
-
- True, i meant it isn't possible for this to be detected at compile time
- or by the standard library. If the compiler did put in runtime checking it
- would have to deal with code such as:
-
- ++*a + ++*b + ++*c + ++*d + ++*e ........
-
- which gets more interesting. Then you might consider pointer to different
- types and so on.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-